package com.zhangjie.apipassenger.interceptor;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Auther: zj
 * @Date: 2024/2/1 - 02 - 01 - 11:42
 * @Description: com.zhangjie.apipassenger.interceptor
 * @version: 1.0
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public JwtInterceptor jwtInterceptor(){
        return new JwtInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(jwtInterceptor())
                // 拦截的路径
                .addPathPatterns("/**")
                // 不拦截的路径
                .excludePathPatterns("/noauthTest") // 测试
                .excludePathPatterns("/verification-code") // 获取验证码
                .excludePathPatterns("/verification-code-check") // 校验验证码
                .excludePathPatterns("/token-refresh") // 刷新token
                .excludePathPatterns("/test-real-time-order/**")
                .excludePathPatterns("/error");
    }
}
